const mysql = require("mysql");

function query(sql,params=[]){
    return new Promise((resolve,reject)=>{
        const connection = mysql.createConnection({
            host:"localhost",
            port:3306,
            user:"root",
            password:"root",
            database:"1803b",
        });
        connection.query(sql,params,function (err,results){
            if(err){
                reject(err)
            }else{
                resolve(results)
            }
        });
        connection.end();
    });
}

module.exports = query;